package org.summerframework.core.validation.constraints;


import org.summerframework.core.validation.IdCardCheckValidate;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 验证身份证
 *
 * @author liaorb
 * @version 1.0
 * @date 2019-06-26 09:27:26
 */
@Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER})
@Retention(RUNTIME)
@Constraint(validatedBy = IdCardCheckValidate.class)
public @interface IdCardCheck {

    //默认错误消息
    String message() default "身份证格式错误.";

    //分组
    Class<?>[] groups() default {};

    //负载
    Class<? extends Payload>[] payload() default {};

    boolean strict() default true;

    //指定多个时使用
    @Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE})
    @Retention(RUNTIME)
    @Documented
    @interface List {
        IdCardCheck[] value();
    }

}
